package com.sitia.jd.util;

import com.alibaba.fastjson2.JSONObject;
import com.sitia.jd.domain.vo.GetCouponResultVo;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.net.URLEncoder;

/**
 * 对京东发送请求的工具类
 */

@RequestMapping("/jdUtil")
@Slf4j
public class JdUtils {

    /**
     * 获取当前用户登陆信息 cookie登陆情况
     * @param cookie 账号cookie
     * @return
     */
    public static String getJdUser(String cookie) {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded; charset=UTF-8");
        RequestBody body = RequestBody.create(mediaType, "lmt=0&body=%7B%22fromSource%22%3A%22wojing%22%2C%22plugin_version%22%3A90570%7D&");
        Request request = new Request.Builder()
                .url("https://api.m.jd.com/client.action?functionId=userBasicInfos&lmt=0&clientVersion=11.3.4&build=98475&client=android&partner=xiaomi001&oaid=05ef33bb1db1da32&eid=eidAd001812166s1OETCSOmdQwGr7Vk87qNIbzhEw82gwHoXE/TIGkfZEoOR9eOcjtC/JmIxGxPHYZeZ6CO4zo5/3W9sak+o/UXF3zBhpUFWEIy3XY1G&sdkVersion=30&lang=zh_CN&harmonyOs=0&networkType=wifi&uts=0f31TVRjBSvO020JfklvYNgL%2BdeHNEe4DYpGv2G6%2FuT2MM7kH45stYfbpHdMRIJapRL%2B%2B9rPNgsEEa3zogdTz0lhVBgqfojqp0%2F3y4xFIxu0M%2FR8cr6lLprt6sR5o5bG1rVErv4t%2BbT67i6k1F0zOgU%2FRed8ncaiYGYJP7naKPLJPlCiAMSwZUFecw%2BHDuYWOzrDno%2FszAOcSy7WbtB2Sw%3D%3D&uemps=0-0&ext=%7B%22prstate%22%3A%220%22%2C%22pvcStu%22%3A%221%22%7D&avifSupport=1&acs=1&ef=1&ep=%7B%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22ts%22%3A1669613292098%2C%22ridx%22%3A-1%2C%22cipher%22%3A%7B%22area%22%3A%22CJvpCJY3D18nEJC4CP8nEJGmDm%3D%3D%22%2C%22d_model%22%3A%22UwVubWvBCtLGcw8%3D%22%2C%22wifiBssid%22%3A%22dW5hbw93bq%3D%3D%22%2C%22osVersion%22%3A%22CJO%3D%22%2C%22d_brand%22%3A%22WQvrb21f%22%2C%22screen%22%3A%22CtS5DsenCNqm%22%2C%22uuid%22%3A%22EJHrDWYzCwU4DwHvYtS0Dm%3D%3D%22%2C%22aid%22%3A%22EJHrDWYzCwU4DwHvYtS0Dm%3D%3D%22%2C%22openudid%22%3A%22EJHrDWYzCwU4DwHvYtS0Dm%3D%3D%22%7D%2C%22ciphertype%22%3A5%2C%22version%22%3A%221.2.0%22%2C%22appname%22%3A%22com.jingdong.app.mall%22%7D&st=1669613304526&sign=f18d144710ef3a4e94f750a64630f152&sv=120")
                .method("POST", body)
                .addHeader("Host", "api.m.jd.com")
                .addHeader("charset", "UTF-8")
                .addHeader("user-agent", "okhttp/3.12.1;jdmall;android;version/11.3.4;build/98475;")
                .addHeader("cache-control", "no-cache")
                .addHeader("Cookie", cookie)
                .addHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8")
                .addHeader("Accept", "*/*")
                .addHeader("Connection", "keep-alive")
                .build();
        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                String jsonResponse = response.body().string();
                log.info("【获取用户登陆信息结果:->】"+jsonResponse );
                return jsonResponse;
                // 处理 JSON 响应
               // System.out.println(jsonResponse);
            } else {
                System.out.println("Error: " + response.code());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        //Response response = client.newCall(request).execute();
        return "获取失败";
    }


    /**
     * 根据cookie获取京东优惠券详细情况
     * @param cookie 账号cookie
     * @return
     */
    public static String getJdCoupon(String cookie) {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded; charset=UTF-8");
        RequestBody body = RequestBody.create(mediaType, "body=%7B%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22ts%22%3A1654255172661%2C%22ridx%22%3A-1%2C%22cipher%22%3A%7B%22body%22%3A%22oyTiYXHfdRVuZIS6StKkCMSiSwnlbwdfdRVuZIS6StKkCMSiSxLrZ2UsEsSnSsmscQPxZVDfowUsEsSnCMSiSxDvYXTtaODldXLlbvH5cQUsEsS1CISiSxD0oWnvStesCIT9%22%7D%2C%22ciphertype%22%3A5%2C%22version%22%3A%221.2.0%22%2C%22appname%22%3A%22com.jingdong.app.mall%22%7D&");
        Request request = new Request.Builder()
                .url("https://api.m.jd.com/client.action?functionId=configCouponList&clientVersion=11.0.2&build=97565&client=android&partner=xiaomi001&oaid=587bd5d259b27807&eid=eidAd61f812205s6EuKWXErHTjCzpdG9Q++tjhLil91K7ucT3tyQADzboPGuwCg1MQ1r+3U0aXXpquZ+ze20NGIThyMYdZQJ9ChpZ21G1YGTIupYVzpm&sdkVersion=30&lang=zh_CN&harmonyOs=0&networkType=UNKNOWN&uts=0f31TVRjBSvW%2FHXSl4sLVkzpP5RdX0WniVk%2BPTpbrGq%2FjvTzSumEW3yZGLK2a3nxfg2l8UsWWPDPd%2BHHLdZOq17AZdYE40tLFNqMtr%2BppmGeUBE2%2BBob1dVOCdV1vf8ChasUP94uydZzKxRKVG4BdRxjGleTx09Q5wNM6j%2BBVpGhpRElEz2hADANgx7w348xJ8mYB8nM26BRxn3t4%2B4TXg%3D%3D&uemps=0-0&ext=%7B%22prstate%22%3A%220%22%2C%22pvcStu%22%3A%221%22%7D&ef=1&ep=%7B%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22ts%22%3A1654255144081%2C%22ridx%22%3A-1%2C%22cipher%22%3A%7B%22d_model%22%3A%22UwVubWvBCtLGcw8%3D%22%2C%22wifiBssid%22%3A%22dW5hbw93bq%3D%3D%22%2C%22osVersion%22%3A%22CJO%3D%22%2C%22d_brand%22%3A%22WQvrb21f%22%2C%22screen%22%3A%22CtS5DsenCNqm%22%2C%22uuid%22%3A%22ZNdrEJC0ZtDwZWUmCJruDK%3D%3D%22%2C%22aid%22%3A%22ZNdrEJC0ZtDwZWUmCJruDK%3D%3D%22%2C%22openudid%22%3A%22ZNdrEJC0ZtDwZWUmCJruDK%3D%3D%22%7D%2C%22ciphertype%22%3A5%2C%22version%22%3A%221.2.0%22%2C%22appname%22%3A%22com.jingdong.app.mall%22%7D&bef=1&st=1654255172661&sign=2c8e8a9e5c3486e2d3757026d6be4056&sv=100")
                .method("POST", body)
                .addHeader("Connection", "Keep-Alive")
                .addHeader("Charset", "UTF-8")
                .addHeader("user-agent", "okhttp/3.12.1;jdmall;android;version/11.0.2;build/97565;")
                .addHeader("Cache-Control", "no-cache")
                .addHeader("Host", "api.m.jd.com")
                .addHeader("Cookie", cookie).addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
                .addHeader("Accept", "*/*")
                .build();
        try (Response response = client.newCall(request).execute()) {
            if (response.isSuccessful()) {
                String jsonResponse = response.body().string();
                log.info("【获取用户优惠券信息结果:->】"+jsonResponse );
                return jsonResponse;
                // 处理 JSON 响应
                // System.out.println(jsonResponse);
            } else {
                System.out.println("Error: " + response.code());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        //Response response = client.newCall(request).execute();
        return "获取失败";
    }

    /**
     * 获取12期
     * @param log
     * @param random
     * @param cookie
     * @return
     */
    public static GetCouponResultVo get12Coupon(String log, String random,String cookie) {

        try {
            log = URLEncoder.encode(log, "UTF-8");
            random = URLEncoder.encode(random, "UTF-8");
        } catch (Exception e) {
            System.out.println("Error while encoding: " + e.getMessage());
        }
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
        String content = "body=%7B%22activityId%22%3A%2227ymdYiFp6M7sA1WkbULRVuERRbX%22%2C%22gridInfo%22%3A%22%22%2C%22transParam%22%3A%22%7B%5C%22bsessionId%5C%22%3A%5C%22d20cc630-7890-4a81-90cf-322dcd3d77b3%5C%22%2C%5C%22babelChannel%5C%22%3A%5C%22%5C%22%2C%5C%22actId%5C%22%3A%5C%2200777715%5C%22%2C%5C%22enActId%5C%22%3A%5C%2227ymdYiFp6M7sA1WkbULRVuERRbX%5C%22%2C%5C%22pageId%5C%22%3A%5C%224597843%5C%22%2C%5C%22encryptCouponFlag%5C%22%3A%5C%221%5C%22%2C%5C%22requestChannel%5C%22%3A%5C%22h5%5C%22%2C%5C%22sfd%5C%22%3A%7B%5C%2298674577%5C%22%3A%5B%5C%2298674578%5C%22%5D%2C%5C%2298674588%5C%22%3A%5B%5C%2298674588%5C%22%5D%2C%5C%2298674576%5C%22%3A%5B%5C%2298674576%5C%22%5D%2C%5C%2298674587%5C%22%3A%5B%5C%2298674588%5C%22%5D%2C%5C%2298674579%5C%22%3A%5B%5C%2298674580%5C%22%5D%2C%5C%2298674578%5C%22%3A%5B%5C%2298674578%5C%22%5D%2C%5C%2298674589%5C%22%3A%5B%5C%2298674590%5C%22%5D%2C%5C%2298656682%5C%22%3A%5B%5C%2298656682%5C%22%5D%2C%5C%2298656685%5C%22%3A%5B%5C%2298656685%5C%22%5D%2C%5C%2298674584%5C%22%3A%5B%5C%2298674584%5C%22%5D%2C%5C%2298674573%5C%22%3A%5B%5C%2298656682%5C%22%5D%2C%5C%2298674583%5C%22%3A%5B%5C%2298674584%5C%22%5D%2C%5C%2298674594%5C%22%3A%5B%5C%2298674594%5C%22%5D%2C%5C%2298674575%5C%22%3A%5B%5C%2298674576%5C%22%5D%2C%5C%2298674586%5C%22%3A%5B%5C%2298674586%5C%22%5D%2C%5C%2298674574%5C%22%3A%5B%5C%2298656685%5C%22%5D%2C%5C%2298674585%5C%22%3A%5B%5C%2298674586%5C%22%5D%2C%5C%2298674591%5C%22%3A%5B%5C%2298674592%5C%22%5D%2C%5C%2298674580%5C%22%3A%5B%5C%2298674580%5C%22%5D%2C%5C%2298674590%5C%22%3A%5B%5C%2298674590%5C%22%5D%2C%5C%2298674593%5C%22%3A%5B%5C%2298674594%5C%22%5D%2C%5C%2298674592%5C%22%3A%5B%5C%2298674592%5C%22%5D%7D%2C%5C%22jdAtHomePage%5C%22%3A%5C%220%5C%22%2C%5C%22utmFlag%5C%22%3A%5C%221%5C%22%2C%5C%22locType%5C%22%3A%5C%221%5C%22%7D%22%2C%22scene%22%3A%223%22%2C%22args%22%3A%22%22%2C%22platform%22%3A%221%22%2C%22orgType%22%3A%222%22%2C%22openId%22%3A%22-1%22%2C%22pageClickKey%22%3A%22-1%22%2C%22eid%22%3A%22HWVZDUX7YLB26MZKGVOKB5XD3QB3L6YKQU56O6PQ7H5CELMVZVHRTJWSHNEZECCDJ6HUC7OXF7VOOQREZQUHSWFVMM%22%2C%22fp%22%3A%22fe14ffcb9388c16022797287cc8a25d4%22%2C%22shshshfp%22%3A%2216d15ee1825514d637955fbf3689efeb%22%2C%22shshshfpa%22%3A%22fc75db62-99f5-cea6-6264-e3be97e4a4de-1698107509%22%2C%22shshshfpb%22%3A%22AAvxEGF-LEiuK8IyHHLReO2lFS9v8__rmU0bAwAAAAAA%22%2C%22childActivityUrl%22%3A%22https%253A%252F%252Fprodev.m.jd.com%252Fmall%252Factive%252F27ymdYiFp6M7sA1WkbULRVuERRbX%252Findex.html%253F_ts%253D1698062658308%2526utm_user%253Dplusmember%2526gx%253DRnEylmJebzPamtQdqYNzVeovhR041ljjaQ%2526ad_od%253Dshare%2526utm_source%253Dandroidapp%2526utm_medium%253Dappshare%2526utm_campaign%253Dt_335139774%2526utm_term%253DCopyURL%2526preventPV%253D1%2526forceCurrentView%253D1%22%2C%22userArea%22%3A%22-1%22%2C%22client%22%3A%22-1%22%2C%22clientVersion%22%3A%22-1%22%2C%22uuid%22%3A%22-1%22%2C%22osVersion%22%3A%22-1%22%2C%22brand%22%3A%22-1%22%2C%22model%22%3A%22-1%22%2C%22networkType%22%3A%22-1%22%2C%22jda%22%3A%22122270672.1698107508703473598701.1698107508.1698107508.1698107508.1%22%2C%22pageClick%22%3A%22Babel_Coupon%22%2C%22actKey%22%3A%22FB199CEBCA0FE11F20898E0DEE5078C0F1D4E8107DEF96439937E4049CEA5F4EE4C4C70CE2E25C325715F1147A56771DDED26C4C9DB3482CC8047CED14E94273622D097F79E66DB6F31E4CE3F1235DE214BCEA4198222A5625027064336513042176C460F92449C1ECEA55F9871F160CE7A57DE136C6D2ECF4708BB6868F1810EB9F343AB403A6D013B33FCEBDE32CA0154D0A2EEA265FDA997521B4346F52CDE0B68428D3EBA77E4BE7AA1ADD37A4EADA2A883A70F1012527A3010A345B7AD851E0DF3CC864B07B38E56C0ACE658B0DFE61D352E9360946AE69C9751F7332BC_bingo%22%2C%22couponSource%22%3A%22manual%22%2C%22couponSourceDetail%22%3A%22-100%22%2C%22channel%22%3A%22%E9%80%9A%E5%A4%A9%E5%A1%94%E4%BC%9A%E5%9C%BA%22%2C%22batchId%22%3A%22%22%2C%22headArea%22%3A%22%22%2C%22mitemAddrId%22%3A%22%22%2C%22geo%22%3A%7B%22lng%22%3A%22%22%2C%22lat%22%3A%22%22%7D%2C%22addressId%22%3A%22%22%2C%22posLng%22%3A%22%22%2C%22posLat%22%3A%22%22%2C%22un_area%22%3A%22%22%2C%22jdv%22%3A%22androidapp%7Ct_335139774%7Cappshare%7CCopyURL%22%2C%22focus%22%3A%22%22%2C%22innerAnchor%22%3A%22%22%2C%22cv%22%3A%222.0%22%2C%22gLng1%22%3A%22%22%2C%22gLat1%22%3A%22%22%2C%22head_area%22%3A%22%22%2C%22log%22%3A%22"+log+"%22%2C%22random%22%3A%22"+random+"%22%2C%22floor_id%22%3A%2298656682%22%7D&screen=1920*1080&client=wh5&clientVersion=1.0.0&sid=&uuid=1698107508703473598701&area=";
        System.out.println("content=>"+content);
        RequestBody body = RequestBody.create(mediaType, content);
        Request request = new Request.Builder()
                .url("https://api.m.jd.com/client.action?functionId=newBabelAwardCollection")
                .method("POST", body)
                .addHeader("authority", "api.m.jd.com")
                .addHeader("accept", "*/*")
                .addHeader("accept-language", "zh-CN,zh;q=0.9")
                .addHeader("cookie", cookie)
                .addHeader("referer", "https://prodev.m.jd.com/mall/active/27ymdYiFp6M7sA1WkbULRVuERRbX/index.html?_ts=1698062658308&utm_user=plusmember&gx=RnEylmJebzPamtQdqYNzVeovhR041ljjaQ&ad_od=share&utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=CopyURL&preventPV=1&forceCurrentView=1")
                .addHeader("user-agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Mobile Safari/537.36")
                .addHeader("sec-ch-ua-platform", "Android")
                .addHeader("content-type", "application/x-www-form-urlencoded")
                .addHeader("Host", "api.m.jd.com")
                .addHeader("Connection", "keep-alive")
                .build();
        try {
            Response response = client.newCall(request).execute();
            String res = response.body().string();
            System.out.println("抢12期jieguo=>"+res);
            JSONObject result = JSONObject.parseObject(res);
            GetCouponResultVo vo = result.toJavaObject(GetCouponResultVo.class);

            return vo;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 获取6期
     * @param log
     * @param random
     * @param cookie
     * @return
     */
    public static GetCouponResultVo get6Coupon(String log, String random,String cookie) {

        try {
            log = URLEncoder.encode(log, "UTF-8");
            random = URLEncoder.encode(random, "UTF-8");
        } catch (Exception e) {
            System.out.println("Error while encoding: " + e.getMessage());
        }
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
        String content = "body=%7B%22activityId%22%3A%2227ymdYiFp6M7sA1WkbULRVuERRbX%22%2C%22gridInfo%22%3A%22%22%2C%22transParam%22%3A%22%7B%5C%22bsessionId%5C%22%3A%5C%221bd3beb7-253d-4ef9-b44a-1ae901f5359e%5C%22%2C%5C%22babelChannel%5C%22%3A%5C%22%5C%22%2C%5C%22actId%5C%22%3A%5C%2200777715%5C%22%2C%5C%22enActId%5C%22%3A%5C%2227ymdYiFp6M7sA1WkbULRVuERRbX%5C%22%2C%5C%22pageId%5C%22%3A%5C%224627436%5C%22%2C%5C%22encryptCouponFlag%5C%22%3A%5C%221%5C%22%2C%5C%22requestChannel%5C%22%3A%5C%22h5%5C%22%2C%5C%22sfd%5C%22%3A%7B%5C%2299110899%5C%22%3A%5B%5C%2299110899%5C%22%5D%2C%5C%2299110877%5C%22%3A%5B%5C%2299110878%5C%22%5D%2C%5C%2299110900%5C%22%3A%5B%5C%2299110901%5C%22%5D%2C%5C%2299110878%5C%22%3A%5B%5C%2299110878%5C%22%5D%2C%5C%2299110901%5C%22%3A%5B%5C%2299110901%5C%22%5D%2C%5C%2299110879%5C%22%3A%5B%5C%2299110880%5C%22%5D%2C%5C%2299110895%5C%22%3A%5B%5C%2299110895%5C%22%5D%2C%5C%2299110874%5C%22%3A%5B%5C%2299110875%5C%22%5D%2C%5C%2299110896%5C%22%3A%5B%5C%2299110897%5C%22%5D%2C%5C%2299110875%5C%22%3A%5B%5C%2299110875%5C%22%5D%2C%5C%2299110897%5C%22%3A%5B%5C%2299110897%5C%22%5D%2C%5C%2299110898%5C%22%3A%5B%5C%2299110899%5C%22%5D%2C%5C%2299110891%5C%22%3A%5B%5C%2299110891%5C%22%5D%2C%5C%2299110880%5C%22%3A%5B%5C%2299110880%5C%22%5D%2C%5C%2299110881%5C%22%3A%5B%5C%2299110882%5C%22%5D%2C%5C%2299110870%5C%22%3A%5B%5C%2299110871%5C%22%5D%2C%5C%2299110892%5C%22%3A%5B%5C%2299110893%5C%22%5D%2C%5C%2299110882%5C%22%3A%5B%5C%2299110882%5C%22%5D%2C%5C%2299110871%5C%22%3A%5B%5C%2299110871%5C%22%5D%2C%5C%2299110893%5C%22%3A%5B%5C%2299110893%5C%22%5D%2C%5C%2299110894%5C%22%3A%5B%5C%2299110895%5C%22%5D%2C%5C%2299110890%5C%22%3A%5B%5C%2299110891%5C%22%5D%7D%2C%5C%22jdAtHomePage%5C%22%3A%5C%220%5C%22%2C%5C%22utmFlag%5C%22%3A%5C%221%5C%22%2C%5C%22locType%5C%22%3A%5C%221%5C%22%7D%22%2C%22scene%22%3A%223%22%2C%22args%22%3A%22%22%2C%22platform%22%3A%221%22%2C%22orgType%22%3A%222%22%2C%22openId%22%3A%22-1%22%2C%22pageClickKey%22%3A%22-1%22%2C%22eid%22%3A%22HWVZDUX7YLB26MZKGVOKB5XD3QB3L6YKQU56O6PQ7H5CELMVZVHRTJWSHNEZECCDJ6HUC7OXF7VOOQREZQUHSWFVMM%22%2C%22fp%22%3A%22fe14ffcb9388c16022797287cc8a25d4%22%2C%22shshshfp%22%3A%22ab387e23c15da2eaeddceee41ce20478%22%2C%22shshshfpa%22%3A%226817ecf7-2724-af3c-122d-e18ca736cc13-1698198031%22%2C%22shshshfpb%22%3A%22AAriUfWSLEgQWey4nWaEsuSoIH4GhpPDYDh8awAAAAAA%22%2C%22childActivityUrl%22%3A%22https%253A%252F%252Fprodev.m.jd.com%252Fmall%252Factive%252F27ymdYiFp6M7sA1WkbULRVuERRbX%252Findex.html%253F_ts%253D1698062658308%2526utm_user%253Dplusmember%2526gx%253DRnEylmJebzPamtQdqYNzVeovhR041ljjaQ%2526ad_od%253Dshare%2526utm_source%253Dandroidapp%2526utm_medium%253Dappshare%2526utm_campaign%253Dt_335139774%2526utm_term%253DCopyURL%2526preventPV%253D1%2526forceCurrentView%253D1%22%2C%22userArea%22%3A%22-1%22%2C%22client%22%3A%22-1%22%2C%22clientVersion%22%3A%22-1%22%2C%22uuid%22%3A%22-1%22%2C%22osVersion%22%3A%22-1%22%2C%22brand%22%3A%22-1%22%2C%22model%22%3A%22-1%22%2C%22networkType%22%3A%22-1%22%2C%22jda%22%3A%22122270672.1698198030867460894659.1698198030.1698198030.1698198030.1%22%2C%22pageClick%22%3A%22Babel_Coupon%22%2C%22actKey%22%3A%22779D268375E5D50E0D7D1C54C28059EEF90DE3A2CF8F3FE90753DDBF87D42D450207E254EEA4F78E9E9A63E7747D1381580412C28F635FDF2DF4A8ED84389A5D35012529691C97B397099AEF06289AAC4E13AFDEE75A8D4063F71EEFE527CC1D2BF21C8BB8B8C99AA8A96412F8AE852D54D79996E57A69B2C24FE6818A0204E92841A262CFB7233F64A5A09916B4EA0B16A5E204FD7C12C38135CA4FC182C0377272A7A062D64FF0F3D81BE6D2DC34B827EE6AB3B702D3F6191C31AEAFF5ACF5566CA794D5C51EA5FEB33B342FB4C1AF30AC6A196DA508E00A17C62E00B4C24C_bingo%22%2C%22couponSource%22%3A%22manual%22%2C%22couponSourceDetail%22%3A%22-100%22%2C%22channel%22%3A%22%E9%80%9A%E5%A4%A9%E5%A1%94%E4%BC%9A%E5%9C%BA%22%2C%22batchId%22%3A%22%22%2C%22headArea%22%3A%22%22%2C%22mitemAddrId%22%3A%22%22%2C%22geo%22%3A%7B%22lng%22%3A%22%22%2C%22lat%22%3A%22%22%7D%2C%22addressId%22%3A%22%22%2C%22posLng%22%3A%22%22%2C%22posLat%22%3A%22%22%2C%22un_area%22%3A%22%22%2C%22jdv%22%3A%22androidapp%7Ct_335139774%7Cappshare%7CCopyURL%22%2C%22focus%22%3A%22%22%2C%22innerAnchor%22%3A%22%22%2C%22cv%22%3A%222.0%22%2C%22gLng1%22%3A%22%22%2C%22gLat1%22%3A%22%22%2C%22head_area%22%3A%22%22%2C%22log%22%3A%22"+log+"%22%2C%22random%22%3A%22"+random+"%22%2C%22floor_id%22%3A%2299111957%22%7D&screen=1200*1644&client=wh5&clientVersion=1.0.0&sid=&uuid=1698198030867460894659&area=&uemps=&appid=wh5&functionId=newBabelAwardCollection&h5st=20231025094044941%3B3855534602311377%3B35fa0%3Btk02w55741a5b41lMXgzeDN4Mk1jA-3Xl1BNaW9o33Xja-b75UjaC27C3YVORCqOZZOBbEjUSVIeIKCYCh09ZC0wKkww%3B5b7ac4612224052e7e848aab3539c521446557d91006eb35bfb01f77bf5b528d%3B3.1%3B1698198044941%3B62f4d401ae05799f14989d31956d3c5ff69bf9d5a722facd4df405c9452a670e06cef39a50ad1e9b78fa7ec6af1b14462c66909b783cc0ffb13050ced02e49070bc5d4ee7032485bfc20c2e30c0845dfe81934dd60aae9a8f399af1bbf1a7f117c4cd240764bad38a4ab46c9016e159db6fef7b0c35249a9e4004888003cc5ccbb778377a9b23219207a1760662a4468e2d14e92b967d5a0007cc2b88070c68e877bcd67d17b72276ecf3411aebf17ffbeaee412389d4bea20bd6bd852cc5b4dfcb29b1fe9d7bc29ddbb7123f8ce6e8a5efd07757383ced2569bfa82e349bf098208019f5e3b2e3bfa6a7c35d1080d09159357913ccd079c20f016ff9d3309b57b9143d37a3763d70fd45efa6903aeedcac2e3d3b89983ad6cbc07cbe31101e7636422c84946755d341947ad003de29cb4cfccad835efe26148e412e549462c616a02694e8121ee0f9ac8a7c9a2b5961&eid=HWVZDUX7YLB26MZKGVOKB5XD3QB3L6YKQU56O6PQ7H5CELMVZVHRTJWSHNEZECCDJ6HUC7OXF7VOOQREZQUHSWFVMM&x-api-eid-token=jdd03HWVZDUX7YLB26MZKGVOKB5XD3QB3L6YKQU56O6PQ7H5CELMVZVHRTJWSHNEZECCDJ6HUC7OXF7VOOQREZQUHSWFVMMAAAAMLMR6YSEYAAAAADXR5EYO2Q77IAMX";
        System.out.println("content=>"+content);
        RequestBody body = RequestBody.create(mediaType, content);
        Request request = new Request.Builder()
                .url("https://api.m.jd.com/client.action?functionId=newBabelAwardCollection")
                .method("POST", body)
                .addHeader("authority", "api.m.jd.com")
                .addHeader("accept", "*/*")
                .addHeader("accept-language", "zh-CN,zh;q=0.9")
                .addHeader("cookie", cookie)
                .addHeader("referer", "https://prodev.m.jd.com/mall/active/27ymdYiFp6M7sA1WkbULRVuERRbX/index.html?_ts=1698062658308&utm_user=plusmember&gx=RnEylmJebzPamtQdqYNzVeovhR041ljjaQ&ad_od=share&utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=CopyURL&preventPV=1&forceCurrentView=1")
                .addHeader("user-agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Mobile Safari/537.36")
                .addHeader("sec-ch-ua-platform", "Android")
                .addHeader("content-type", "application/x-www-form-urlencoded")
                .addHeader("Host", "api.m.jd.com")
                .addHeader("Connection", "keep-alive")
                .build();
        try {
            Response response = client.newCall(request).execute();
            String res = response.body().string();
            System.out.println("抢6期jieguo=>"+res);
            JSONObject result = JSONObject.parseObject(res);
            GetCouponResultVo vo = result.toJavaObject(GetCouponResultVo.class);

            return vo;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /*public  static UnionOpenPromotionCommonGetResponse getRebateUrl(String SERVER_URL,String accessToken,String appKey,String appSecret) throws Exception {
        JdClient client=new DefaultJdClient(SERVER_URL,accessToken,appKey,appSecret);
        UnionOpenPromotionCommonGetRequest request=new UnionOpenPromotionCommonGetRequest();
        PromotionCodeReq promotionCodeReq=new PromotionCodeReq();
        request.setPromotionCodeReq(promotionCodeReq);
        request.setVersion("1.0");
        return client.execute(request);
    }*/
}
